package androidx.fragment.app;

import androidx.lifecycle.s;
import androidx.lifecycle.t;
import androidx.lifecycle.u;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

final class p extends s {
    private static final t.b i = new a();

    /* renamed from: c  reason: collision with root package name */
    private final HashMap<String, Fragment> f649c = new HashMap<>();

    /* renamed from: d  reason: collision with root package name */
    private final HashMap<String, p> f650d = new HashMap<>();
    private final HashMap<String, u> e = new HashMap<>();
    private final boolean f;
    private boolean g = false;
    private boolean h = false;

    static class a implements t.b {
        a() {
        }

        public <T extends s> T a(Class<T> cls) {
            return new p(true);
        }
    }

    p(boolean z) {
        this.f = z;
    }

    static p j(u uVar) {
        return (p) new t(uVar, i).a(p.class);
    }

    /* access modifiers changed from: protected */
    public void d() {
        if (m.p0(3)) {
            "onCleared called for " + this;
        }
        this.g = true;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || p.class != obj.getClass()) {
            return false;
        }
        p pVar = (p) obj;
        return this.f649c.equals(pVar.f649c) && this.f650d.equals(pVar.f650d) && this.e.equals(pVar.e);
    }

    /* access modifiers changed from: package-private */
    public boolean f(Fragment fragment) {
        if (this.f649c.containsKey(fragment.mWho)) {
            return false;
        }
        this.f649c.put(fragment.mWho, fragment);
        return true;
    }

    /* access modifiers changed from: package-private */
    public void g(Fragment fragment) {
        if (m.p0(3)) {
            "Clearing non-config state for " + fragment;
        }
        p pVar = this.f650d.get(fragment.mWho);
        if (pVar != null) {
            pVar.d();
            this.f650d.remove(fragment.mWho);
        }
        u uVar = this.e.get(fragment.mWho);
        if (uVar != null) {
            uVar.a();
            this.e.remove(fragment.mWho);
        }
    }

    /* access modifiers changed from: package-private */
    public Fragment h(String str) {
        return this.f649c.get(str);
    }

    public int hashCode() {
        return (((this.f649c.hashCode() * 31) + this.f650d.hashCode()) * 31) + this.e.hashCode();
    }

    /* access modifiers changed from: package-private */
    public p i(Fragment fragment) {
        p pVar = this.f650d.get(fragment.mWho);
        if (pVar != null) {
            return pVar;
        }
        p pVar2 = new p(this.f);
        this.f650d.put(fragment.mWho, pVar2);
        return pVar2;
    }

    /* access modifiers changed from: package-private */
    public Collection<Fragment> k() {
        return this.f649c.values();
    }

    /* access modifiers changed from: package-private */
    public u l(Fragment fragment) {
        u uVar = this.e.get(fragment.mWho);
        if (uVar != null) {
            return uVar;
        }
        u uVar2 = new u();
        this.e.put(fragment.mWho, uVar2);
        return uVar2;
    }

    /* access modifiers changed from: package-private */
    public boolean m() {
        return this.g;
    }

    /* access modifiers changed from: package-private */
    public boolean n(Fragment fragment) {
        return this.f649c.remove(fragment.mWho) != null;
    }

    /* access modifiers changed from: package-private */
    public boolean o(Fragment fragment) {
        if (!this.f649c.containsKey(fragment.mWho)) {
            return true;
        }
        return this.f ? this.g : !this.h;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("FragmentManagerViewModel{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append("} Fragments (");
        Iterator<Fragment> it = this.f649c.values().iterator();
        while (it.hasNext()) {
            sb.append(it.next());
            if (it.hasNext()) {
                sb.append(", ");
            }
        }
        sb.append(") Child Non Config (");
        Iterator<String> it2 = this.f650d.keySet().iterator();
        while (it2.hasNext()) {
            sb.append(it2.next());
            if (it2.hasNext()) {
                sb.append(", ");
            }
        }
        sb.append(") ViewModelStores (");
        Iterator<String> it3 = this.e.keySet().iterator();
        while (it3.hasNext()) {
            sb.append(it3.next());
            if (it3.hasNext()) {
                sb.append(", ");
            }
        }
        sb.append(')');
        return sb.toString();
    }
}
